Skip to content

FE-629: Compile Petrinaut user code through an HIR to buffer-native programs#8981

Merged
kube merged 20 commits into
mainfrom
cf/fe-629-add-an-intermediate-representation-for-petrinaut
Jul 14, 2026
Merged

FE-629: Compile Petrinaut user code through an HIR to buffer-native programs#8981
kube merged 20 commits into
mainfrom
cf/fe-629-add-an-intermediate-representation-for-petrinaut

Conversation

@kube

@kube kube commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

Replace Petrinaut’s Babel-based user-code path with a typed HIR pipeline. Dynamics, transition rates, kernels, and expression metrics are lowered and checked in the language worker, then emitted as buffer-native programs for simulation workers.

This enables static diagnostics and analysis while removing per-call token-record decoding from simulation hot paths. Raw user text is never evaluated directly at runtime.

🔍 What does this change?

  • Adds the HIR lowering, schema typechecking, analyses, linting, artifact format, and buffer-program emitters in petrinaut-core.
  • Moves artifact compilation to the LSP worker and threads validated artifacts through single-run and Monte Carlo simulation.
  • Runs generated programs against packed f64/u64/u8 frame views with baked attribute offsets and strides.
  • Adds HIR diagnostics (99001+); unsupported or non-compilable code is a blocking error, while warnings/hints leave Play available.
  • Updates Petrinaut documentation for the supported subset and metric-array operations.
  • Removes @babel/standalone, the legacy user-code and metric compilers, record decode/encode adapters, the exploratory DSL sketch, the HIR Playground Storybook story, and its unmaintained benchmark harness.

Scenarios and visualizers are unchanged: scenarios retain their once-per-run sandboxed path, and visualizers remain UI JSX.

⚠️ Behaviour change

User TypeScript outside the supported analyzable subset now produces an editor error instead of executing. The shipped examples compile through the HIR pipeline.

🔗 Related links

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies an npm-publishable library and I have added a changeset file(s)

📜 Does this require a change to the docs?

The changes in this PR:

  • require changes to docs which are made as part of this PR

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🛡 What tests cover this?

  • Unit coverage for lowering, typechecking, analyses, buffer emission, artifact validation, string metrics, actual-mode metrics, and control-flow semantics.
  • Example-model coverage ensuring supported dynamics, lambdas, kernels, and metrics compile to buffer programs.

❓ How to test this?

  1. Run yarn workspace @hashintel/petrinaut-core test:unit run.
  2. Open Petrinaut, load an example such as Supply Chain, inspect Diagnostics, run a simulation, and run a Monte Carlo experiment with expression metrics.

Copilot AI review requested due to automatic review settings July 8, 2026 23:49
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Jul 14, 2026 6:25pm
petrinaut Ready Ready Preview, Comment Jul 14, 2026 6:25pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Jul 14, 2026 6:25pm

@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

PR Summary

High Risk
This is a core compilation and execution-path rewrite for all user dynamics, rates, kernels, and metrics, with a breaking compatibility boundary for unsupported TypeScript and fingerprint-gated artifacts at runtime.

Overview
Replaces the Babel/new Function path for dynamics, lambdas, kernels, and metrics with a HIR pipeline: lower a supported TypeScript subset, typecheck against the net, emit versioned (v4) buffer programs, and run them on packed frame views in simulation and Monte Carlo workers. @babel/standalone is removed; compilation happens in the LSP worker via compileHirArtifacts, while workers load artifacts through @hashintel/petrinaut-core/hir-runtime so the full compiler (and typescript) stays out of worker bundles.

Runtime contract: lambdas/kernels/metrics now take f64/u64/u8 views and offsets instead of decoded TokenRecord objects; kernels defer distributions through an ABI sink. Stale artifacts are rejected using a compilation-input fingerprint. Code outside the supported subset fails at compile time with source-spanned diagnostics rather than running.

Supporting changes: actual-mode timeline frames pack count-only coloured markings into token buffers so HIR metrics work there; numeric markings are normalized with Math.floor for finite values. New dependency-cruiser/D2 architecture diagrams and updated authoring docs describe the new pipeline. Scenarios and visualizers are unchanged.

Reviewed by Cursor Bugbot for commit 8ac159e. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team area/apps > hash.design Affects the `hash.design` design site (app) labels Jul 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces Petrinaut's Babel + eval execution of user code (dynamics, firing rates, transition kernels, metrics) with a new HIR (high-level intermediate representation) pipeline. User code is lowered from a TypeScript subset to a typed, spanned, JSON-serializable expression tree, typechecked against the token schema, analyzed (distribution DAGs, dependency sets, determinism), and emitted as buffer-native programs that read/write packed frame buffers directly with attribute offsets/strides baked in as constants. This removes @babel/standalone and per-call token decode/encode from the simulation hot loops (worker bundles shrink ~3 MB → ~40 kB), surfaces out-of-subset code as blocking LSP error diagnostics, and threads compiled artifacts through the simulation/Monte-Carlo start flows. It fits into the petrinaut-core/petrinaut packages as deliberately private API and lays groundwork for a future DSL frontend and WASM/GPU backends.

Changes:

  • New HIR pipeline in petrinaut-core/src/hir/ (lowering, typecheck, analyses, lints, buffer emitters) plus engine execution of buffer programs and deletion of Babel/compile-user-code/compile-metric/record adapters.
  • Artifact compilation moved into the LSP worker (sdcpn/compileHirArtifacts) and threaded through simulation/experiment configs; metric drawers and the timeline now rely on LSP diagnostics + async HIR artifacts instead of synchronous compileMetric.
  • LSP/UX: HIR lints (codes 99001+, source: "hir"), error-only Play gating with an amber warnings-only indicator, and updated user docs.

Reviewed changes

Copilot reviewed 95 out of 96 changed files in this pull request and generated no comments.

Show a summary per file
File Description
yarn.lock Drops @babel/standalone/@types/babel__standalone; adds optional typescript peer dependency for petrinaut-core
.../metrics/view-metric-drawer.tsx Removes synchronous compileMetric compile-check; validation now sourced from metric LSP diagnostics
.../metrics/create-metric-drawer.tsx Same removal of live compileMetric preview compile in the create flow
.../metrics/metric-form.tsx Updates comment to reflect HIR-based compilability rather than compileMetric
.../experiments/create-experiment-drawer.tsx buildMetricSpecs returns ExperimentMetricSpecInput; expression metrics validated for non-empty code, compiled via HIR at experiment start
.../simulation-timeline/use-streaming-data.ts New async useTimelineMetric hook compiling the selected metric via requestHirArtifacts + createHirMetricEvaluator
.../BottomBar/diagnostics-indicator.tsx Adds amber warning status for warnings/hints-only state (Play still allowed)
petrinaut-core/src/hir.ts (+ hir-runtime) New public entry exposing compileHirArtifacts and HIR types
.../simulation/engine/buffer-transition.ts New buffer-ABI transition execution (kernel sinks, UUID lanes, staging)
.../simulation/engine/build-simulation.ts Instantiates buffer programs, validates stale/missing artifacts, allocates reusable scratch
.../simulation/frames/hir-metric.ts New HIR metric evaluator with cached place indices + per-run string-pool rebind
.../simulation/frames/frame-reader.ts, simulation/api.ts getPlaceTokens gains optional color? param (currently ignored)
.../lsp/lib/check-hir.ts HIR diagnostic-code registry and per-item HIR linting (subsetSeverity: "error")
.../simulation-timeline/series-config/metric.ts Timeline metric config switches from places/buildMetricState to an injected evaluator
react/experiments/context Adds ExperimentMetricSpecInput type for pre-artifact metric specs
docs: petri-net-extensions.md, simulation.md Document supported subset (incl. metrics), error/warning split, and error-only Play gating

Copilot AI review requested due to automatic review settings July 9, 2026 16:57
Comment thread libs/@hashintel/petrinaut-core/src/hir/lint.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 95 out of 96 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 9, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 96 out of 97 changed files in this pull request and generated 1 comment.

Comment thread libs/@hashintel/petrinaut-core/benches/bench.mjs Outdated
Comment thread libs/@hashintel/petrinaut-core/src/actual-mode/timeline.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 96 out of 97 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings July 14, 2026 16:17
@github-actions github-actions Bot removed the area/apps > hash.design Affects the `hash.design` design site (app) label Jul 14, 2026
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.68%. Comparing base (82dc297) to head (bb399fd).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8981      +/-   ##
==========================================
- Coverage   59.68%   59.68%   -0.01%     
==========================================
  Files        1371     1371              
  Lines      135555   135555              
  Branches     6066     6066              
==========================================
- Hits        80912    80911       -1     
- Misses      53711    53712       +1     
  Partials      932      932              
Flag Coverage Δ
apps.hash-ai-worker-ts 1.39% <ø> (ø)
apps.hash-api 6.39% <ø> (ø)
blockprotocol.type-system 40.84% <ø> (ø)
local.claude-hooks 0.00% <ø> (ø)
local.harpc-client 51.49% <ø> (ø)
local.hash-backend-utils 1.90% <ø> (ø)
local.hash-graph-sdk 10.02% <ø> (ø)
local.hash-isomorphic-utils 0.18% <ø> (ø)
rust.error-stack 90.89% <ø> (ø)
rust.harpc-codec 84.70% <ø> (ø)
rust.harpc-net 96.19% <ø> (-0.02%) ⬇️
rust.harpc-tower 67.03% <ø> (ø)
rust.harpc-wire-protocol 92.23% <ø> (ø)
rust.hash-codec 72.76% <ø> (ø)
rust.hash-graph-api 7.41% <ø> (ø)
rust.hash-graph-authorization 62.59% <ø> (ø)
rust.hash-graph-embeddings 91.88% <ø> (ø)
rust.hash-graph-store 38.47% <ø> (ø)
rust.hash-graph-temporal-versioning 47.95% <ø> (ø)
rust.hash-graph-types 0.00% <ø> (ø)
rust.hash-graph-validation 84.71% <ø> (ø)
rust.hashql-ast 89.63% <ø> (ø)
rust.hashql-compiletest 28.39% <ø> (ø)
rust.hashql-core 78.98% <ø> (ø)
rust.hashql-diagnostics 72.51% <ø> (ø)
rust.hashql-eval 80.04% <ø> (ø)
rust.hashql-hir 89.09% <ø> (ø)
rust.hashql-mir 87.92% <ø> (ø)
rust.hashql-syntax-jexpr 94.04% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq

codspeed-hq Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 15.38%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 2 regressed benchmarks
✅ 96 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
bit_matrix/dense/iter_row[64] 140.8 ns 170 ns -17.16%
bit_matrix/dense/iter_row[200] 185.8 ns 215 ns -13.57%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing cf/fe-629-add-an-intermediate-representation-for-petrinaut (8ac159e) with main (82dc297)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (d068af2) during the generation of this report, so 82dc297 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@kube kube requested a review from CiaranMn July 14, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 108 out of 111 changed files in this pull request and generated 4 comments.

Comment thread libs/@hashintel/petrinaut-core/src/hir/emit-buffer-js.ts
Comment thread libs/@hashintel/petrinaut/src/react/experiments/provider.tsx
Comment thread libs/@hashintel/petrinaut/docs/petri-net-extensions.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 108 out of 111 changed files in this pull request and generated 2 comments.

Comment thread libs/@hashintel/petrinaut/src/react/simulation/provider.tsx
Comment thread libs/@hashintel/petrinaut-core/src/actual-mode/timeline.ts
Copilot AI review requested due to automatic review settings July 14, 2026 18:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum diff size. Try reducing the number of changed files and lines, and requesting a review from Copilot again.

Merged via the queue into main with commit 03f6a30 Jul 14, 2026
179 of 180 checks passed
@kube kube deleted the cf/fe-629-add-an-intermediate-representation-for-petrinaut branch July 14, 2026 18:48
@hash-worker hash-worker Bot mentioned this pull request Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark results

@rust/hash-graph-benches – Integrations

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$26.7 \mathrm{ms} \pm 196 \mathrm{μs}\left({\color{gray}-0.881 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.35 \mathrm{ms} \pm 17.4 \mathrm{μs}\left({\color{lightgreen}-5.065 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1002 $$12.1 \mathrm{ms} \pm 90.7 \mathrm{μs}\left({\color{gray}-0.611 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$41.8 \mathrm{ms} \pm 403 \mathrm{μs}\left({\color{gray}-0.714 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$13.7 \mathrm{ms} \pm 113 \mathrm{μs}\left({\color{lightgreen}-6.669 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1527 $$22.9 \mathrm{ms} \pm 197 \mathrm{μs}\left({\color{gray}0.158 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$27.6 \mathrm{ms} \pm 190 \mathrm{μs}\left({\color{gray}-0.382 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.69 \mathrm{ms} \pm 24.0 \mathrm{μs}\left({\color{gray}-3.204 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$12.9 \mathrm{ms} \pm 97.1 \mathrm{μs}\left({\color{gray}-2.230 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.76 \mathrm{ms} \pm 26.7 \mathrm{μs}\left({\color{gray}-0.061 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.95 \mathrm{ms} \pm 24.2 \mathrm{μs}\left({\color{gray}-0.844 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 52 $$3.34 \mathrm{ms} \pm 24.4 \mathrm{μs}\left({\color{gray}0.138 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.14 \mathrm{ms} \pm 32.0 \mathrm{μs}\left({\color{gray}-0.753 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.48 \mathrm{ms} \pm 19.8 \mathrm{μs}\left({\color{gray}-0.760 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 108 $$4.09 \mathrm{ms} \pm 24.0 \mathrm{μs}\left({\color{gray}-2.181 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.36 \mathrm{ms} \pm 29.1 \mathrm{μs}\left({\color{gray}-0.630 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.44 \mathrm{ms} \pm 24.9 \mathrm{μs}\left({\color{gray}-0.097 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$4.02 \mathrm{ms} \pm 27.5 \mathrm{μs}\left({\color{gray}-0.879 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.56 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}-3.536 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.49 \mathrm{ms} \pm 14.6 \mathrm{μs}\left({\color{gray}-0.237 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 2 $$2.56 \mathrm{ms} \pm 15.2 \mathrm{μs}\left({\color{gray}-2.894 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.80 \mathrm{ms} \pm 14.8 \mathrm{μs}\left({\color{gray}-3.834 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.60 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}-3.929 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.79 \mathrm{ms} \pm 13.3 \mathrm{μs}\left({\color{gray}-3.308 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$3.03 \mathrm{ms} \pm 18.2 \mathrm{μs}\left({\color{gray}-0.723 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.71 \mathrm{ms} \pm 14.7 \mathrm{μs}\left({\color{gray}-0.378 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 26 $$2.97 \mathrm{ms} \pm 18.0 \mathrm{μs}\left({\color{gray}-0.032 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.40 \mathrm{ms} \pm 17.8 \mathrm{μs}\left({\color{gray}-0.709 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.94 \mathrm{ms} \pm 18.1 \mathrm{μs}\left({\color{gray}-0.582 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 27 $$3.28 \mathrm{ms} \pm 21.9 \mathrm{μs}\left({\color{gray}0.197 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.32 \mathrm{ms} \pm 17.3 \mathrm{μs}\left({\color{gray}-0.919 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.92 \mathrm{ms} \pm 16.3 \mathrm{μs}\left({\color{gray}-0.096 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.29 \mathrm{ms} \pm 16.2 \mathrm{μs}\left({\color{gray}-0.153 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$41.8 \mathrm{ms} \pm 247 \mathrm{μs}\left({\color{gray}-0.499 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$32.6 \mathrm{ms} \pm 220 \mathrm{μs}\left({\color{gray}-1.922 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$35.4 \mathrm{ms} \pm 222 \mathrm{μs}\left({\color{gray}1.10 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$39.1 \mathrm{ms} \pm 1.14 \mathrm{ms}\left({\color{red}24.8 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$40.7 \mathrm{ms} \pm 237 \mathrm{μs}\left({\color{gray}-1.936 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$49.3 \mathrm{ms} \pm 262 \mathrm{μs}\left({\color{gray}-0.187 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$39.5 \mathrm{ms} \pm 224 \mathrm{μs}\left({\color{gray}0.933 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$88.4 \mathrm{ms} \pm 517 \mathrm{μs}\left({\color{gray}-0.873 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$46.4 \mathrm{ms} \pm 4.01 \mathrm{ms}\left({\color{red}39.3 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$249 \mathrm{ms} \pm 1.18 \mathrm{ms}\left({\color{lightgreen}-8.140 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$10.8 \mathrm{ms} \pm 69.8 \mathrm{μs}\left({\color{gray}-0.151 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$10.9 \mathrm{ms} \pm 64.6 \mathrm{μs}\left({\color{gray}0.275 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$10.9 \mathrm{ms} \pm 60.8 \mathrm{μs}\left({\color{gray}-0.928 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$10.8 \mathrm{ms} \pm 56.8 \mathrm{μs}\left({\color{gray}-0.626 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$10.8 \mathrm{ms} \pm 64.9 \mathrm{μs}\left({\color{gray}-0.261 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$10.8 \mathrm{ms} \pm 62.2 \mathrm{μs}\left({\color{gray}-0.252 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$11.0 \mathrm{ms} \pm 71.8 \mathrm{μs}\left({\color{gray}0.638 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$10.9 \mathrm{ms} \pm 64.0 \mathrm{μs}\left({\color{gray}-0.894 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$10.9 \mathrm{ms} \pm 54.9 \mathrm{μs}\left({\color{gray}-0.274 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$11.0 \mathrm{ms} \pm 56.8 \mathrm{μs}\left({\color{gray}-1.266 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$11.2 \mathrm{ms} \pm 56.6 \mathrm{μs}\left({\color{gray}0.662 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$11.3 \mathrm{ms} \pm 73.8 \mathrm{μs}\left({\color{gray}0.985 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$11.2 \mathrm{ms} \pm 57.1 \mathrm{μs}\left({\color{gray}-2.238 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$11.2 \mathrm{ms} \pm 66.7 \mathrm{μs}\left({\color{gray}-0.089 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$11.3 \mathrm{ms} \pm 64.4 \mathrm{μs}\left({\color{gray}-0.588 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$11.3 \mathrm{ms} \pm 68.3 \mathrm{μs}\left({\color{gray}1.46 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$11.4 \mathrm{ms} \pm 75.4 \mathrm{μs}\left({\color{gray}1.10 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$11.3 \mathrm{ms} \pm 66.9 \mathrm{μs}\left({\color{gray}-1.362 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$11.3 \mathrm{ms} \pm 63.3 \mathrm{μs}\left({\color{gray}0.450 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: bf5a9ef5-dc3b-43cf-a291-6210c0321eba $$8.46 \mathrm{ms} \pm 49.9 \mathrm{μs}\left({\color{gray}0.989 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$58.8 \mathrm{ms} \pm 528 \mathrm{μs}\left({\color{gray}4.65 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$111 \mathrm{ms} \pm 649 \mathrm{μs}\left({\color{gray}2.89 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$66.0 \mathrm{ms} \pm 483 \mathrm{μs}\left({\color{gray}4.74 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$75.4 \mathrm{ms} \pm 602 \mathrm{μs}\left({\color{gray}3.34 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$84.2 \mathrm{ms} \pm 515 \mathrm{μs}\left({\color{gray}2.57 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$90.1 \mathrm{ms} \pm 558 \mathrm{μs}\left({\color{gray}3.65 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$42.7 \mathrm{ms} \pm 323 \mathrm{μs}\left({\color{gray}1.92 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$70.1 \mathrm{ms} \pm 365 \mathrm{μs}\left({\color{gray}0.058 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$48.5 \mathrm{ms} \pm 323 \mathrm{μs}\left({\color{gray}0.953 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$58.0 \mathrm{ms} \pm 425 \mathrm{μs}\left({\color{gray}1.96 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$59.6 \mathrm{ms} \pm 426 \mathrm{μs}\left({\color{gray}-0.136 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$59.8 \mathrm{ms} \pm 388 \mathrm{μs}\left({\color{gray}0.529 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$120 \mathrm{ms} \pm 732 \mathrm{μs}\left({\color{gray}-3.841 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$131 \mathrm{ms} \pm 787 \mathrm{μs}\left({\color{gray}-3.775 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$22.7 \mathrm{ms} \pm 239 \mathrm{μs}\left({\color{red}22.5 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$528 \mathrm{ms} \pm 1.16 \mathrm{ms}\left({\color{gray}-2.035 \mathrm{\%}}\right) $$ Flame Graph

@hash-worker hash-worker Bot mentioned this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

4 participants